//
//  OffcialForumController.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/19.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "OffcialForumController.h"

@interface OffcialForumController ()

@end

@implementation OffcialForumController


- (void)dealloc
{
    [_myWeb release];
    [_myurl release];
    [_myname release];
    [_imgV release];
    [_myal release];
    [_label1 release];
    [_playTimer release];
 
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = self.myname;
    
    self.tuAdd = 1;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
  
       
    self.myWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 49 - 64)];

    
    NSString *urlstr = self.myurl;
    
    NSURL *url = [NSURL URLWithString:urlstr];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    [self.view addSubview:self.myWeb];
    
    self.myWeb.delegate = self;
    
    [self.myWeb loadRequest:request];
    
    [self.myWeb setScalesPageToFit:YES];// 自适应
    
    //2. 禁用拖拽时的反弹效果
    [(UIScrollView *)[[self.myWeb subviews] objectAtIndex:0] setBounces:NO];
    
    


    
    
 
    
     self.addpage = NO;
    
    [self.myWeb release];
    
    
    self.playTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(myGif) userInfo:nil repeats:YES];

    
    

    
    

 }

// ************************************************************


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    
    
    
           return YES;
    
}

- (void )webViewDidFinishLoad:(UIWebView  *)webView  //网页加载完成的时候调用
{
    
    self.addpage = YES;
    
//      NSLog(@"加载完成");
    
     [self.view bringSubviewToFront:self.myWeb];
    
    [self.playTimer invalidate];// 停止
    
     
   
    
}

//  网页加载开始的时候调用

//- (void)webViewDidStartLoad:(UIWebView  *)webView   //网页开始加载的时候调用
- (void)webViewDidStartLoad:(UIWebView *)webView
{
  

    
    
  
}


- (void)webView:(UIWebView *)webView  didFailLoadWithError:(NSError *)error //网页加载错误的时候调用
{
    
//     UIAlertView *aa = [[UIAlertView alloc] initWithTitle:nil message:@"网络不给力" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
//    [aa show];
//    [aa release];

    
}


- (void)myGif
{
    
    self.tuAdd ++;
    self.imgV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    NSString *str = [NSString stringWithFormat:@"mytu%ld", self.tuAdd];
    self.imgV.image = [UIImage imageNamed:str];
    [self.view addSubview:self.imgV];
    [_imgV release];
    if (self.tuAdd == 8) {
        self.tuAdd = 1;
    }

}






//  ----------------------------------------  工具视图



















- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
